import Vue from 'vue'
import VueRouter from 'vue-router'
import Blogs from "../views/Blogs";
import Login from '../views/Login'
import BlogDetail from "@/views/BlogDetail";
import BlogEdit from "@/views/BlogEdit";
import Jokes from "@/views/Jokes";
import Music from "@/views/Music";
import Forecast from "@/views/Forecast";
import MusicPro from "@/views/MusicPro";

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    redirect: '/blogs'
  },
  {
    path: '/blogs',
    name: 'Blogs',
    component: Blogs
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/blog/add',
    name: 'BlogAdd',
    component: BlogEdit,
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/blog/:blogId',
    name: 'BlogDetail',
    component: BlogDetail
  },
  {
    path: '/blog/:blogId/edit',
    name: 'BlogEdit',
    component: BlogEdit,
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/jokes',
    name: 'Jokes',
    component: Jokes
  },
  {
    path: '/music',
    name: 'Music',
    component: Music
  },
  {
    path: '/forecast',
    name: 'Forecast',
    component: Forecast
  },
  {
    path: '/musicPro',
    name: 'MusicPro',
    component: MusicPro
  }
]

const router = new VueRouter({
  mode: 'hash', // 原来是history，如果要部署项目，要改为hash
  base: process.env.BASE_URL,
  routes
})

export default router
